from app.user.models import Role, User


def init_role(enterprise_id='cs_school'):
    objs = Role.load_from_json()
    for o in objs:
        o.enterprise_id = enterprise_id
    Role.objects.insert(objs)


def load_perms(enterprise_id='cs_school', roles=None):
    Role.load_perms_from_json(enterprise_id, roles)


def init_account_run():
    user = User(
        name='zhangsan',
        cname='张三',
        email='zhangsan@qq.com',
        phone='12345678901'
    ).save()
    user.reset_password()
    user.save()
    user.set_roles(['manager'])


def init_account():

    return
